package cn.gson.springboot.model.service.afterservice;

import cn.gson.springboot.model.dao.afterdao.ServerDao;
import cn.gson.springboot.model.mapper.aftermapper.ServerMapper;
import cn.gson.springboot.model.pjos.Emp;
import cn.gson.springboot.model.pjos.Server;
import cn.gson.springboot.model.vo.aftervo.MaintainChartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ServerService {

    @Autowired
    ServerMapper mapper;
    @Autowired
    ServerDao dao;

    //分页查询客户服务
    public List<Server> serverPage(Integer states,String search){
        return mapper.servPage(states,search);
    }

    //新增客户服务表
    public void addServ(Server serv){
        serv.setServDelete(1);
        dao.save(serv);
    }

    //通过客户服务id查询客户服务表
    public Server selectServ(Integer servId){
        return mapper.servAll(servId);
    }

    //查询所有员工
    public List<Emp> selectEmp(){
        return mapper.empAll();
    }

    //逻辑删除
    public void deleteByServId(Integer servId){
        if(servId != null){
            Server serv = dao.findById(servId).get();
            serv.setServDelete(0);
            dao.save(serv);
        }
    }

    //服务类型分布
    public List<MaintainChartVo> selectServByType(){
        return mapper.servByType();
    }

    //服务方式分布
    public List<MaintainChartVo> selectServByMode(){
        return mapper.servByMode();
    }

    //客服花费时间分布
    public List<MaintainChartVo> selectServByDate(){
        return mapper.servByDate();
    }

    //客户服务次数分布
    public List<MaintainChartVo> selectCustomerByDate(){
        return mapper.customerByDate();
    }

    //客户服务月度统计的月份
    public List<String> selectServiceMonth(){
        return mapper.serviceByMonth();
    }

    //客户服务月度统计数
    public List<Integer> selectServiceCount(){
        return mapper.serviceByCount();
    }

    //处理完成月度统计的月份
    public List<String> selectFinishMonth(){
        return mapper.finishByMonth();
    }

    //处理完成月度统计数
    public List<Integer> selectFinishCount(){
        return mapper.finishByCount();
    }
}
